package server.game.objects.doors;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.util.List;

import core.util.Misc;

public class MDoorHandler {

	private final List<MDoor> doors = new LinkedList<MDoor>();

	public MDoorHandler() {
		Misc.println("Miracle Door Handler - Started...");
		loadDoors();
	}

	public void loadDoors() {
		Misc.println("Miracle Door Handler - Loading Doors...");
		try {
			BufferedReader in = new BufferedReader(new FileReader("./data/doors.cfg"));
			String data = null;
			while ((data = in.readLine()) != null) {
				if (!data.startsWith("//") && !data.startsWith("[")) {
					if (data.startsWith("door = ")) {
						final String doorInfo = data.substring(8);
						final String doorData[] = doorInfo.split(" ");
						final int id = Integer.parseInt(doorData[0]);
						final int x = Integer.parseInt(doorData[1]);
						final int y = Integer.parseInt(doorData[2]);
						final int z = Integer.parseInt(doorData[3]);
						final int f = Integer.parseInt(doorData[4]);
					}
				} else if (data.startsWith("[ENDOFDOORS]")) {
					in.close();
					in = null;
				}
			}
		} catch (final Exception e) {
			e.printStackTrace();
		}
	}

}
